package Asgmt1.element;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Roll {

    private boolean base6 = false;
    private boolean center5 = false;
    private boolean top4 = false;
    private int deductionScore = 0;
    private int score = 0;

    public int rollDice() {
        Dice d = new Dice();
        int[] dice = d.rollDice();
        List<Integer> list = Arrays.stream(dice).boxed().collect(Collectors.toList());
        if (!base6 && list.contains(6)){
            base6 = true;
            deductionScore = 6;
        }
        if (base6 && !center5 && list.contains(5)){
            center5 = true;
            deductionScore += 5;
        }
        if (center5 && !top4 && list.contains(4)){
            top4 = true;
            deductionScore += 4;
        }
        if (base6 && center5 && top4){
            for (int x : dice) {
                score += x;
            }
            score -= deductionScore;
        }
        deductionScore = 0;
        System.out.println("Roll: " + d);
        System.out.println("Status: Base " + base6 + ", Center " + center5 + ", Top " + top4);
        System.out.println("Score: " + score);
        return score;
    }
}
